#!/usr/bin/env python3.9
from PIL import Image, ImageDraw, ImageFont

COLOURSPACE="YCbCr"
CARDSIZE=(800,616)
#CARDSIZE=(640,496)
(xmax, ymax) = CARDSIZE
foreground = (255,128,128)
background = (0,128,128)
textcol = (232,128,192)

im = Image.new(mode=COLOURSPACE, size=CARDSIZE, color=background)


for y in range (8,ymax):
    for x in range (0,xmax):
        c = x & ((x//3)-1)
        if c == 0:
            im.putpixel ((x, y), foreground)
        else:
            im.putpixel ((x, y), background)


d = ImageDraw.Draw(im)
fnt = ImageFont.truetype("/usr/home/cjb/.fonts/PetMe64.ttf", 32)
xx = xmax // 4
d.text ((xx,4), "VK2CJB", font=fnt, fill=textcol)
d.text ((xx,44), "Drift checker", font=fnt, fill=textcol)
d.text ((xx,88), "Look for S-bending", font=fnt, fill=textcol)
d.text ((xx,122), "(use a ruler!)", font=fnt, fill=textcol)


imrgb = im.convert("RGB")
s = "driftcheck-" + str(xmax) + "x" + str(ymax) + ".png"
print (s)
imrgb.save(s)
